﻿using Himp.TaskScheduling.Hangfire.Controllers;
using Himp.TaskScheduling.Hangfire;
using Microsoft.AspNetCore.Mvc;
using Hangfire;
using Himp.TaskScheduling.Hangfire.Jobs;

namespace Himp.TaskScheduling
{
    [ApiController]
    [Route("[controller]")]
    public class InitJobsController : ControllerBase
    {
        private readonly ILogger<InitJobsController> _logger;

        public InitJobsController(ILogger<InitJobsController> logger)
        {
            _logger = logger;
        }

        [HttpGet(Name = "Init")]
        public bool Init()
        {
            RecurringJob.AddOrUpdate<ZYOperateRecordJob>("化验-制样操作记录信息任务",
                job => job.StartAsync(new CancellationToken()), "*/5 * * * *");
            RecurringJob.AddOrUpdate<SamplePreparationRecWorker>("化验-制样结果转标准化验任务",
                job => job.StartAsync(new CancellationToken()), "*/5 * * * *");
            RecurringJob.AddOrUpdate<BoltInfo1Job>("存样1-存样柜数据同步",
                job => job.StartAsync(new CancellationToken()), "*/2 * * * *");
            RecurringJob.AddOrUpdate<BoltInfo2Job>("存样2-存样柜数据同步",
                job => job.StartAsync(new CancellationToken()), "*/2 * * * *");
            //RecurringJob.AddOrUpdate<AuditStandardTestTaskWorker>("化验-自动审核标准化验任务",
            //    job => job.StartAsync(new CancellationToken()), "*/5 * * * *");

            RecurringJob.AddOrUpdate<TBSampleJob>("化验-机器人测水_化验结果",
                job => job.StartAsync(new CancellationToken()), "*/5 * * * *");
            RecurringJob.AddOrUpdate<RILS1810ViewMJob>("化验-水分数据",
                job => job.StartAsync(new CancellationToken()), "*/5 * * * *");
            RecurringJob.AddOrUpdate<RILS1810ViewAJob>("化验-灰分化验结果",
                job => job.StartAsync(new CancellationToken()), "*/5 * * * *");
            RecurringJob.AddOrUpdate<RILS1810ViewVJob>("化验-挥发分数据",
                job => job.StartAsync(new CancellationToken()), "*/5 * * * *");
            RecurringJob.AddOrUpdate<RILS1810ViewSJob>("化验-硫数据",
                job => job.StartAsync(new CancellationToken()), "*/5 * * * *");
            RecurringJob.AddOrUpdate<RILS1810ViewCalorJob>("化验-量热仪数据",
                job => job.StartAsync(new CancellationToken()), "*/5 * * * *");
            RecurringJob.AddOrUpdate<RILS1810ViewChnJob>("化验-碳氢氮数据",
                job => job.StartAsync(new CancellationToken()), "*/5 * * * *");

            return true;
        }
    }
}
